<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

function smarty_block_customer($params, $tagdata, &$smarty, &$repeat) { 
	$smarty->CI->load->model('customers/customer_model');
	$html = "";
	if ($smarty->CI->agent->is_mobile()){
		
		$smarty->assign('customer_to_html',$html);
	}else{
		if (($customer = $smarty->CI->customer_model->get_customer_login())){
			//var_dump($customer);
			$html .= "<div class=\"customer-nav\">\n"
			      ."<span class=\"customer-name\">{$customer['username']}</span>\n"
				  ."<span class=\"customer-dayvip\"><span class=\"v-label\">Vip: </span><span class=\"v-value\">{$customer['vip']} ngày</span></span>\n"
				  ."<span class=\"customer-logout\"><a title=\"Thoat\" href=\"".create_url('customers/customer/logout')."\">Thoát</a></span>"
			      ."</div>\n";
			
		}else{
			$html .="<div class=\"customer-nav\">\n";
			$html .="<a href=\"".create_url('dang-nhap')."\" title=\"Đăng nhập\">Đăng nhập</a>\n";
			$html .="<a href=\"".create_url('dang-ky')."\" title=\"Đăng ký\">Đăng ký</a>\n";
			$html .="</div>\n";
		}
		$smarty->assign('customer_to_html',$html);
	}
	echo $tagdata;
}
